﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>通用数据字典列表</title>
    <link rel="stylesheet" type="text/css" href="../Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="../Content/Css/list.css" />
    <script type="text/javascript" src="../Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="../Scripts/json2.js"></script>
    <script type="text/javascript" src="../Scripts/common.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/Plugin/om-yj-container.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <script type="text/javascript">
        var listGrid, colData = [], searchPanel, defaultSort, defaultWhere, currentUID, gridTitle, searchField, exportField, viewSql;
        var showSearchPanel, goOn = true;

        $(document).ready(function () {
            art.dialog.data('selectValue', undefined);
            viewSql = getQueryStringByName("vsql");
            searchField = "Code,Name";
            defaultSort = { sortby: 'UID', sortdir: 'ASC' };
            colData = [
                { header: '部门编码', name: 'Code', width: 120, align: 'center' },
                { header: '部门名称', name: 'Name', width: 150, align: 'center' }
            ];
            defaultWhere = { where: " 1=1 " };
            listGrid = $('#listgrid').omGrid({
                width: '100%',
                height: 300,
                autoFit: true,
                title: gridTitle,
                singleSelect: true,
                limit: 30,
                onRowDblClick: function (rowIndex, rowData, event) {
                    art.dialog.data('selectValue', rowData.UID + '$' + rowData.Code + '$' + rowData.Name);
                    art.dialog.close();
                },
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: '',
                colModel: colData
            });
            showSearchPanel();
        });

        showSearchPanel = function () {
            $('span#button-search').omButton({
                icons: { left: '../Content/Images/List/search.png' }, width: 80,
                onClick: function (event) {
                    var custWhere = ' ';
                    if ($('#Content').val().length == 0) {
                        custWhere += ' 1=1 '
                    }
                    else {
                        var searcharr = searchField.split(',');
                        for (var i = 0, l = searcharr.length; i < l; i++) {
                            custWhere += " " + searcharr[i] + ' LIKE ' + '\'%' + $('#Content').val() + '%\' ' + 'OR';
                        }
                        custWhere = custWhere.substring(0, custWhere.length - 2);
                    }
                    listGrid.omGrid({
                        extraData: $.extend({ where: defaultWhere.where + ' AND (' + custWhere + ')' }, defaultSort),
                        dataSource: '../Handler/grid.ashx?view=(' + escape(viewSql) + ') AS '
                    });
                }
            });
            $('span#button-clear').omButton({
                icons: { left: '../Content/Images/List/search.png' }, width: 80,
                onClick: function (event) {
                    $('#Content').val("");
                }
            });
            $('span#button-cancel').omButton({
                icons: { left: '../Content/Images/cancel.png' }, width: 80,
                onClick: function (event) {
                    art.dialog.close();
                }
            });
            $('span#button-confirm').omButton({
                icons: { left: '../Content/Images/accept.png' }, width: 80,
                onClick: function (event) {
                    var selectRow = listGrid.omGrid("getSelections", true);
                    if (selectRow.length == 1) {
                        var codename = ''
                        $.each(selectRow[0], function (index, value) {
                            codename += value + "$";
                        });
                        art.dialog.data('selectValue', codename);
                        art.dialog.close();
                    }
                    else {
                        $.omMessageBox.alert({
                            content: '请至少选择一条数据',
                            onClose: function () { }
                        });
                    }
                }
            });
            searchPanel = $('#search-panel').omPanel({
                width: 'fit',
                title: "查询条件",
                collapsible: true,
                collapsed: false,
                closable: false
            });
        };
    </script>
</head>
<body>
    <div id="search-panel">
        <table>
            <tr>
                <td>
                    <span class="label">关键字：</span>
                    <input type="text" class="input-text" id="Content" />
                    <span id="button-search">搜索</span>
                    <span id="button-clear">清空</span>
                    <span id="button-confirm">确认</span>
                    <span id="button-cancel">取消</span>
                </td>
            </tr>
        </table>
    </div>
    <table id="listgrid"></table>
</body>
</html>
